package com.weds.frame.common.util;

import java.util.Random;
import java.util.UUID;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2023/3/31 10:01
 */
public class RandomUtil {

    //获取指定位数随机数字
    public static String getRandomNumber(Integer num) {
        String v = "";
        for (int i = 0; i < num; i++) {
            String n = String.valueOf((int)(Math.random()*10));
            v +=n;
        }
        return v;
    }

    //生成uuid
    public static String getUUID() {
        String uuid = UUID.randomUUID().toString().replace("-", "");
        return uuid;
    }

    //获取指定位数随机数字+大写字母
    public static String getRandomString(int length){
        String str="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random=new Random();
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<length;i++){
            int number=random.nextInt(36);
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }
}
